<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: JnlpController</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">JnlpController</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/app/controllers/jnlp_controller_rb.html">
                app/controllers/jnlp_controller.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="ApplicationController.html">
                ApplicationController
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000021">getXmlproperty</a>&nbsp;&nbsp;
      <a href="#M000020">make</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000021" class="method-detail">
        <a name="M000021"></a>

        <div class="method-heading">
          <a href="#M000021" class="method-signature">
          <span class="method-name">getXmlproperty</span><span class="method-args">(name,value)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000021-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/jnlp_controller.rb, line 77</span>
77:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">getXmlproperty</span>(<span class="ruby-identifier">name</span>,<span class="ruby-identifier">value</span>)
78:   <span class="ruby-value str">&quot;&lt;property name=\&quot;&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;\&quot; value=\&quot;&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">value</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;\&quot;/&gt;\n&quot;</span>;
79:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000020" class="method-detail">
        <a name="M000020"></a>

        <div class="method-heading">
          <a href="#M000020" class="method-signature">
          <span class="method-name">make</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000020-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/jnlp_controller.rb, line 3</span>
 3:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">make</span>
 4:   <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">$cache</span>.<span class="ruby-identifier">nil?</span>)<span class="ruby-keyword kw">then</span>
 5:     <span class="ruby-ivar">@content</span>=<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-value str">&quot;public/kerjodando.jnlp&quot;</span>){<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span><span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>}
 6:     <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-value str">&quot;the message should be show once in around-running&quot;</span>)
 7:     <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">'$$title'</span>,<span class="ruby-value str">'dragens'</span>)
 8:     <span class="ruby-identifier">$cache</span>=<span class="ruby-ivar">@content</span>
 9:   <span class="ruby-keyword kw">end</span>
10: <span class="ruby-comment cmt">#  str=File.dirname(request.protocol &lt;&lt; request.host_with_port &lt;&lt; (request.path.split('?',2)[0]));</span>
11:     <span class="ruby-identifier">str</span>=<span class="ruby-identifier">request</span>.<span class="ruby-identifier">protocol</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">host_with_port</span> 
12:   <span class="ruby-ivar">@content</span>=<span class="ruby-identifier">$cache</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">'$$codebase'</span>,<span class="ruby-identifier">str</span>)
13:   <span class="ruby-identifier">puts</span> <span class="ruby-identifier">str</span>
14:  <span class="ruby-comment cmt"># @content.gsub!('$$href',(str &lt;&lt; '/Dev-test/kerjodando.jnlp'))</span>
15:  <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">'$$href'</span>,<span class="ruby-identifier">request</span>.<span class="ruby-identifier">request_uri</span>)
16:  <span class="ruby-identifier">url</span>=<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:server</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">'/'</span>,<span class="ruby-value">5</span>)[<span class="ruby-value">3</span>]
17: 
18:   <span class="ruby-identifier">s</span>=<span class="ruby-constant">Swarm</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>,<span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span>[<span class="ruby-value str">&quot;url = :url &quot;</span>,{<span class="ruby-identifier">:url=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">url</span>}])
19:   <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">'$$icon'</span>,(<span class="ruby-value str">'images/kerjodando_pic/'</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">pic_url</span>))
20:   
21:   <span class="ruby-identifier">replace_str</span> = <span class="ruby-identifier">getXmlproperty</span>(<span class="ruby-value str">'user_public_ip'</span>,<span class="ruby-identifier">request</span>.<span class="ruby-identifier">remote_ip</span>)
22:   <span class="ruby-identifier">puts</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">remote_ip</span>
23:   <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-value str">&quot;request ip=&gt;&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">request</span>.<span class="ruby-identifier">remote_ip</span>)
24:   <span class="ruby-identifier">request</span>.<span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">key</span>,<span class="ruby-identifier">value</span><span class="ruby-operator">|</span><span class="ruby-identifier">replace_str</span><span class="ruby-operator">&lt;&lt;</span><span class="ruby-identifier">getXmlproperty</span>(<span class="ruby-identifier">key</span>,<span class="ruby-identifier">value</span>)}
25:   <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">'$$properties'</span>,<span class="ruby-identifier">replace_str</span>)
26:   
27:   <span class="ruby-ivar">@content_type</span>=<span class="ruby-value str">'application/x-java-jnlp'</span>
28:   <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Content-Type&quot;</span>] = <span class="ruby-ivar">@content_type</span>
29:   <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Cache-Control&quot;</span>]=<span class="ruby-value str">'private,post-check=90,pre-check=100'</span>
30:   <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;pragma&quot;</span>]=<span class="ruby-value str">'no-cache'</span>
31:   <span class="ruby-identifier">swarm_url</span>= <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:server</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">'//'</span>)[<span class="ruby-value">1</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">'/'</span>)[<span class="ruby-value">1</span>]
32:   <span class="ruby-identifier">s</span>=<span class="ruby-constant">Swarm</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>,<span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span>[<span class="ruby-value str">&quot;url = :url&quot;</span>,{<span class="ruby-identifier">:url=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">swarm_url</span>}])
33:   <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">s</span>.<span class="ruby-identifier">nil?</span>) <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:controller=</span><span class="ruby-operator">&gt;</span><span class="ruby-value str">&quot;index&quot;</span> <span class="ruby-keyword kw">end</span>
34:   
35:   <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">session</span>[<span class="ruby-identifier">:user</span>].<span class="ruby-identifier">nil?</span>)
36:     <span class="ruby-identifier">uc</span>=<span class="ruby-constant">UserConnection</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>,<span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span>[<span class="ruby-value str">&quot;user_id = 0 and ip =:ip and thetime &gt; :time &quot;</span>,{<span class="ruby-identifier">:ip=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">request</span>.<span class="ruby-identifier">remote_ip</span>,<span class="ruby-identifier">:time=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">6</span>.<span class="ruby-identifier">minutes</span>.<span class="ruby-identifier">ago</span>}])
37:     <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">uc</span>.<span class="ruby-identifier">nil?</span>)
38:       <span class="ruby-constant">UserConnection</span>.<span class="ruby-identifier">create</span>(
39:       <span class="ruby-identifier">:id=</span><span class="ruby-operator">&gt;</span><span class="ruby-value str">'null'</span>,
40:       <span class="ruby-identifier">:user_id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">session</span>[<span class="ruby-identifier">:user</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-value str">'0'</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">session</span>[<span class="ruby-identifier">:user</span>][<span class="ruby-identifier">:id</span>],
41:       <span class="ruby-identifier">:swarm_id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">s</span>.<span class="ruby-identifier">id</span>, 
42:       <span class="ruby-identifier">:ip=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">request</span>.<span class="ruby-identifier">remote_ip</span>,
43:       <span class="ruby-identifier">:port=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">443</span>,
44:       <span class="ruby-identifier">:thetime=</span><span class="ruby-operator">&gt;</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>
45:       )
46:     <span class="ruby-keyword kw">else</span>
47:       <span class="ruby-identifier">uc</span>.<span class="ruby-identifier">swarm_id</span>=<span class="ruby-identifier">s</span>.<span class="ruby-identifier">id</span>
48:       <span class="ruby-identifier">uc</span>.<span class="ruby-identifier">thetime</span>=<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>
49:       <span class="ruby-identifier">uc</span>.<span class="ruby-identifier">save</span>
50:     <span class="ruby-keyword kw">end</span>
51:   <span class="ruby-keyword kw">else</span>
52:    
53:     <span class="ruby-identifier">count</span>=<span class="ruby-constant">UserConnection</span>.<span class="ruby-identifier">count</span>(<span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span>[<span class="ruby-value str">&quot;user_id = :user_id and thetime &gt; :thetime&quot;</span>,{<span class="ruby-identifier">:user_id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">session</span>[<span class="ruby-identifier">:user</span>].<span class="ruby-identifier">id</span>,<span class="ruby-identifier">:thetime=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">6</span>.<span class="ruby-identifier">minutes</span>.<span class="ruby-identifier">ago</span>}])
54:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">count</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">2</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>]=<span class="ruby-value str">&quot;you just can join 2 swarms.&quot;</span> 
55:     <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:back</span> 
56:     <span class="ruby-keyword kw">return</span> 
57:     <span class="ruby-keyword kw">end</span>
58:      <span class="ruby-identifier">uc</span>=<span class="ruby-constant">UserConnection</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>,<span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span>[<span class="ruby-value str">&quot;user_id = :user_id and swarm_id = :swarm_id and thetime &gt; :time&quot;</span>,{<span class="ruby-identifier">:user_id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">session</span>[<span class="ruby-identifier">:user</span>].<span class="ruby-identifier">id</span>,<span class="ruby-identifier">:time=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">6</span>.<span class="ruby-identifier">minutes</span>.<span class="ruby-identifier">ago</span>,<span class="ruby-identifier">:swarm_id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">s</span>.<span class="ruby-identifier">id</span>}])
59:     <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">uc</span>.<span class="ruby-identifier">nil?</span>)
60:       <span class="ruby-constant">UserConnection</span>.<span class="ruby-identifier">create</span>(
61:       <span class="ruby-identifier">:id=</span><span class="ruby-operator">&gt;</span><span class="ruby-value str">'null'</span>,
62:       <span class="ruby-identifier">:user_id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">session</span>[<span class="ruby-identifier">:user</span>].<span class="ruby-identifier">id</span>,
63:       <span class="ruby-identifier">:swarm_id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">s</span>.<span class="ruby-identifier">id</span>,
64:       <span class="ruby-identifier">:ip=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">request</span>.<span class="ruby-identifier">remote_ip</span>,
65:       <span class="ruby-identifier">:port=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">443</span>,
66:       <span class="ruby-identifier">:thetime=</span><span class="ruby-operator">&gt;</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>      
67:       )
68:      <span class="ruby-keyword kw">else</span>
69:       <span class="ruby-identifier">uc</span>.<span class="ruby-identifier">thetime</span>=<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>
70:       <span class="ruby-identifier">uc</span>.<span class="ruby-identifier">save</span>
71:     <span class="ruby-keyword kw">end</span>
72:   <span class="ruby-keyword kw">end</span>
73:    <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-value str">&quot;request.remote_ip =&gt; &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">request</span>.<span class="ruby-identifier">remote_ip</span><span class="ruby-operator">+</span><span class="ruby-value str">&quot;time=&gt;&quot;</span><span class="ruby-operator">+</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">to_s</span><span class="ruby-operator">+</span><span class="ruby-value str">&quot;vincent messege jnlp=&gt;\n&quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@content</span><span class="ruby-operator">+</span><span class="ruby-value str">&quot;\n end vicent messege&quot;</span>)
74:   <span class="ruby-identifier">render</span> <span class="ruby-identifier">:layout=</span><span class="ruby-operator">&gt;</span><span class="ruby-keyword kw">false</span>
75:   
76:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>